package org.example.springioc01.config;

import org.example.springioc01.bean.Dog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

//注解告诉spring这是一个配置类,配置类在启动容器的时候会加载配置类
@Configuration
public class DogConfig {

    @Primary
    @Bean
    public Dog dog(){
        Dog dog = new Dog();
        dog.setName("xixi11");
        return dog;
    }


    //@ConditionalOnBean(name = "bll")
    @Bean
    public Dog dog1(){
        Dog dog = new Dog();
        dog.setName("xixi");
        return dog;
    }

    @Bean
    public Dog dog02(){
        Dog dog = new Dog();
        dog.setName("hahaha");
        return dog;
    }
}
